//author:kakake
var Model = /** @class */ (function () {
    function Model() {
    }
    return Model;
}());

//author:kakake
var Common = /** @class */ (function () {
    function Common() {
    }
    return Common;
}());

//author:kakake
var tsFrontShowDao = /** @class */ (function () {
    function tsFrontShowDao() {
        this.data = {
            //42.192.250.43
            //10.0.4.5
            dbConn: TSLobsterAPI.DbHelper.setdbconn('42.192.250.43', 'CloudCMS', 'sa', 'Lobster@123')
        };
    }
    tsFrontShowDao.prototype.getindexdata = function (websiteid) {
        var strsql = "select * from CMS_IndexSetting where websiteid=@websiteid and delflag=0";
        return TSLobsterAPI.DbHelper.DbGetJsonData(this.data.dbConn, strsql, { websiteid: websiteid }, null);
    };
    tsFrontShowDao.prototype.getindexdata2 = function (websiteid, workid) {
        var strsql = "select * from CMS_IndexSetting where workid=@workid and websiteid=@websiteid";
        return TSLobsterAPI.DbHelper.DbGetJsonData(this.data.dbConn, strsql, { workid: workid, websiteid: websiteid }, null);
    };
    tsFrontShowDao.prototype.gettitledata = function (websiteid, workid) {
        var strsql = "select nid,nodename from cms_node where workid=@workid and websiteid=@websiteid and nodestatus=1 and ParentID=-1 and IsDel=0 Order by NodeSort";
        return TSLobsterAPI.DbHelper.DbGetJsonData(this.data.dbConn, strsql, { workid: workid, websiteid: websiteid }, null);
    };
    tsFrontShowDao.prototype.getitemdata = function (id, pageInfo) {
        var strsql = "SELECT ID,CID,NodeID,Title,Intraduce,PicPath,ReleaseTime,TotalHit FROM CMS_BaseContext \
        where NodeID=@id and IsDel=0 and Status=99";
        return TSLobsterAPI.DbHelper.DbGetJsonData(this.data.dbConn, strsql, { id: id }, pageInfo);
    };
    tsFrontShowDao.prototype.getcontextdata = function (id) {
        var strsql = "SELECT a.CID,NodeID,Title,Intraduce,PicPath,ReleaseTime,b.U_Cont,a.TotalHit,a.LastUpdateTime FROM CMS_BaseContext a\
        LEFT JOIN CMS_U_Article b on a.ID=b.ID \
        where a.ID=@id";
        return TSLobsterAPI.DbHelper.DbGetJsonObject(this.data.dbConn, strsql, { id: id });
    };
    tsFrontShowDao.prototype.updatetotalhit = function (cid) {
        var strsql = "update CMS_BaseContext set TotalHit=TotalHit+1 where Cid=@cid;\
           update CMS_BaseContextManage set TotalHit=TotalHit+1 where Cid=@cid";
        return TSLobsterAPI.DbHelper.DbExecuteUpdate(this.data.dbConn, strsql, { cid: cid });
    };
    return tsFrontShowDao;
}());

//author:kakake
var tsFrontShowService = /** @class */ (function () {
    function tsFrontShowService() {
    }
    return tsFrontShowService;
}());

//author:kakake
var tsFrontShowController = /** @class */ (function () {
    function tsFrontShowController() {
        this.data = {
            dbConn: TSLobsterAPI.Program.GetDbConn()
        };
        this.dao = new tsFrontShowDao();
    }
    tsFrontShowController.prototype.getindexdata = function () {
        var websiteid = TSLobsterAPI.Program.RequestQuery("websiteid", "0");
        var data = this.dao.getindexdata(websiteid);
        return { data: data };
    };
    tsFrontShowController.prototype.getindexdata2 = function () {
        var websiteid = TSLobsterAPI.Program.RequestQuery("websiteid", "0");
        var workid = TSLobsterAPI.Program.RequestQuery("workId", "0");
        var data = this.dao.getindexdata2(websiteid, workid);
        return { data: data };
    };
    tsFrontShowController.prototype.gettitledata = function () {
        var websiteid = TSLobsterAPI.Program.RequestQuery("websiteid", "0");
        var workid = TSLobsterAPI.Program.RequestQuery("workId", "0");
        var arrlist = [];
        var list = this.dao.gettitledata(websiteid, workid);
        list.forEach(function (res) {
            var item = {};
            item["NID"] = res["nid"];
            item["NodeName"] = res["nodename"];
            arrlist.push(item);
        });
        return { data: arrlist };
    };
    tsFrontShowController.prototype.getitemdata = function () {
        var pageInfo = {
            key: "ID",
            page: parseInt(TSLobsterAPI.Program.RequestQuery("page", "1")),
            perPage: parseInt(TSLobsterAPI.Program.RequestQuery("pagesize", "999")),
            totalRecord: 100,
            totalPage: 0
        };
        var id = TSLobsterAPI.Program.RequestQuery("id", "0");
        var list = this.dao.getitemdata(id, pageInfo);
        return { data: list, more: (pageInfo.page < pageInfo.totalPage) };
    };
    tsFrontShowController.prototype.getcontextdata = function () {
        var id = TSLobsterAPI.Program.RequestQuery("id", "0");
        var item = this.dao.getcontextdata(id);
        return { data: item };
    };
    tsFrontShowController.prototype.updatetotalhit = function () {
        var cid = TSLobsterAPI.Program.RequestQuery("cid", "0");
        this.dao.updatetotalhit(cid);
        return { result: true };
    };
    return tsFrontShowController;
}());

